package com.cold.demo.quartz;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author: zyc
 */
@SpringBootApplication
public class QuartzApplication {


    public static void main(String[] args) {
        ConfigurableApplicationContext context = SpringApplication.run(QuartzApplication.class);
        JdbcTemplate                   jdbcTemplate    = context.getBean(JdbcTemplate.class);
        List<Map<String, Object>> query = jdbcTemplate.query("select * from user", new RowMapper<Map<String, Object>>() {

            @Override
            public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException {
                Map<String, Object> map = new HashMap<>();
                map.put("id",rs.getInt(1));
                map.put("name",rs.getObject(2));
                return map;
            }
        });

        System.out.println(query);
    }
}
